package triangle;

import java.util.ArrayList;
import java.util.List;

public class Test {
    public String str1 = "welcome to XT";
    public String str2 = "come";


    public void delet(List<Character> characters1 , List<Character> characters2){
        for (int i = 0; i < characters1.size(); i++) {
            for (int j = 0; j < characters2.size(); j++) {
                if(characters1.get(i) == characters2.get(j)){
                    characters1.remove(characters1.get(i));
                }
            }
        }
    }


    public void trans(String str1, String str2){
        List<Character> characters = new ArrayList<>();
        for (int i = 0; i < str1.length(); i++) {
            for (int j = 0; j < str2.length(); j++) {
                if(str1.charAt(i) == str2.charAt(j)){
                    characters.add(str1.charAt(i));
                }
            }
        }
        for (int i = 0; i < characters.size(); i++) {
            System.out.print(characters.get(i));
        }
    }

    public static void main(String[] args) {
        Test test = new Test();
        List<Character> characters = new ArrayList<>();
        test.trans(test.str1, test.str2);

    }

    public static void main1(String[] args) {
        Test test = new Test();

        List<Character> del1 = new ArrayList<>();
        List<Character> del2 = new ArrayList<>();

        for (int i = 0; i < test.str1.length(); i++) {
            del1.add(test.str1.charAt(i));
        }
        for (int i = 0; i < test.str2.length(); i++) {
            del2.add(test.str2.charAt(i));
        }

        test.delet(del1,del2);

        for (int i = 0; i < del1.size(); i++) {
            System.out.print(del1.get(i));
        }
    }
}
